package com.atguigu.datastream.day03;

import org.apache.flink.api.java.io.TextInputFormat;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.FileProcessingMode;

import java.util.Arrays;
import java.util.List;

/**
 * ClassName: Flink_01_Source_Collection
 * Package: com.atguigu.day03
 * Description:
 *              从文件读取数据
 * @Author ChenJun
 * @Create 2023/4/8 16:27
 * @Version 1.0
 */
public class Flink_02_Source_File {
    public static void main(String[] args) throws Exception {
        //1.获取Flink运行流环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //2.设置并行度
        env.setParallelism(1);

        //3.从文件读取数据
//        DataStreamSource<String> streamSource = env.readTextFile("input/word.txt");

        DataStreamSource<String> streamSource = env.readFile(new TextInputFormat(new Path()), "input/word.txt", FileProcessingMode.PROCESS_CONTINUOUSLY, 200);

        //4.打印
        streamSource.print();

        //5.执行
        env.execute();



    }
}
